import { Button, Tooltip } from 'antd';
import { Fragment } from 'react';
import { PlusCircleOutlined, EditOutlined, EyeOutlined } from '@ant-design/icons';
import { stateOfRendering } from '../common';
import { history } from 'umi';
import { fieldFlowExport, getKeyRouter, getTenantID } from '@/utils';

// Table表格的配置
const getTableColumns = () => {
  return [
    {
      title: '资产名称',
      dataIndex: 'id',
      key: 'id',
      visible: true,
      width: 165,
      unDrag: false,
      //   fixed: 'left',
      //   sorter: (a: any, b: any) => (a?.id > b?.id ? 1 : -1),
      // render: (text: string | null) => ColumnsRenderFun({ text, wordNum: 100 }),
    },
    {
      title: '资产仓库',
      dataIndex: 'applyInfo',
      key: 'applyInfo',
      //   fixed: 'left',
      visible: true,
      width: 150,
      unDrag: false,
      //   sorter: (a: any, b: any) => (a?.fullName > b?.fullName ? 1 : -1),
      render: (text: string | null, record: Record<string, any>) => {
        return <a style={{ color: '100%', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis', display: 'block' }}>{text}</a>;
      },
    },
    {
      title: '资产类型',
      dataIndex: 'applyState',
      key: 'applyState',
      visible: true,
      width: 140,
      unDrag: false,
      //   sorter: (a: any, b: any) => (a?.materialType > b?.materialType ? 1 : -1),
      // render: (text: string | null) => DictionaryRenderFun({ text }),
    },
    {
      title: '资产剩余数量',
      dataIndex: 'workflowID',
      key: 'workflowID',
      visible: true,
      width: 185,
      unDrag: false,
      //   sorter: (a: any, b: any) => (a?.specInfo > b?.specInfo ? 1 : -1),
      // render: (text: string | null) => ColumnsRenderFun({ text }),
    },
    {
      title: '资产申请数量',
      dataIndex: 'applyStartTime',
      key: 'applyStartTime',
      visible: true,
      width: 150,
      unDrag: false,
      //   sorter: (a: any, b: any) => (a?.modelNum > b?.modelNum ? 1 : -1),
      // render: (text: string | null) => ColumnsRenderFun({ text }),
    },
    {
      title: (
        <div style={{ width: '100%', textAlign: 'center' }}>
          <Button type="link" size="small" icon={<PlusCircleOutlined />} className="manageBtntTxtStyle">
            添加
          </Button>
        </div>
      ),
      dataIndex: 'operation',
      key: 'operation',
      width: 80,
      visible: true,
      unDrag: true,
      fixed: 'right',
      render: (_: string, record: Record<string, any>) => {
        return (
          <Fragment>
            {
              <Button
                onClick={() => {
                  history.push({
                    pathname: `/assettransfer/add/:${getKeyRouter()}${getKeyRouter()}`,
                    state: {
                      pageType: 'view',
                    },
                  });
                }}
                type={'link'}
                size={'small'}
                icon={<EyeOutlined />}
              >
                查看
              </Button>
            }
            {
              <Button
                type={'link'}
                size={'small'}
                icon={<EditOutlined />}
                onClick={() => {
                  // setIsShowAddModal({
                  //   isShow: true,
                  //   recordObj: {},
                  //   clickType: 'add',
                  // })
                }}
              >
                编辑
              </Button>
            }
          </Fragment>
        );
      },
    },
  ];
};

export { getTableColumns };
